package cn.com.generaldata.os.service.indicator_evaluation.prosperity_analysis;

import org.apache.commons.lang3.Validate;

import cn.com.generaldata.jsme_indicator_system.entity.IndicatorEvaluation;
import cn.com.generaldata.os.service.indicator_constant.ProvinceIndicatorConstant;
import cn.com.generaldata.os.service.indicator_evaluation.IndicatorEvaluationCalculateService;
import cn.com.generaldata.os.vo.IndicatorAccountVO;

/**
 * 消费品零售总额增速评估指标计算类.
 */
public class GoodsSalesIncreateCalculateService extends IndicatorEvaluationCalculateService {

	/** 消费品零售总额 */
	private String saleGoods = ProvinceIndicatorConstant.SALE_GOODS_NAME;
	/** 零售价格指数 */
	private String salePrice = ProvinceIndicatorConstant.SALE_PRICE_NAME;

	@Override
	protected Double calculate(IndicatorEvaluation indicator, IndicatorAccountVO indicatorAccountVO) {
		Double saleGoodsValue = getInputOrAccountingIndicatorValue(indicatorAccountVO,
				indicatorAccountVO.getYear(), saleGoods);
		Validate.isTrue(saleGoodsValue != null);
		Double salePriceValue = getInputOrAccountingIndicatorValue(indicatorAccountVO,
				indicatorAccountVO.getYear(), salePrice);
		Validate.isTrue(indicatorAccountVO != null);
		Double goodsComparable = saleGoodsValue * 100 / salePriceValue;
		Double saleGoodsValueLast = getInputOrAccountingIndicatorValue(indicatorAccountVO,
				indicatorAccountVO.getYear() - 1, saleGoods);
		Validate.isTrue(saleGoodsValueLast != null);
		return (goodsComparable / saleGoodsValueLast) - 1;
	}

}
